import { PATH } from './constant';
export function handlerPath(path) {
  if (!path) return;
  let list = path.split('/');
  if (list.length > 0) {
    if (!list[0]) {
      list = list.slice(1);
    }
    let pathList = [];
    for (let item of list) {
      pathList.push({ title: PATH[item], path: `/${item}` });
    }
    return pathList;
  }
  return;
}

export function getParams(search) {
  if (!search) return;
  search = search.substring(1);
  let list = search.split('&');
  let params = {};
  list.forEach(element => {
    let obj = element.split('=');
    const key = obj[0];
    const value = obj[1];
    Object.assign(params, { key: value });
  });
  return params;
}
